<template>
  <div>
    <div>
      <el-row type="flex" justify="space-around">
        <el-col v-for="(item, index) in userRecommend" :span="5" class="al-m-top-10px" :key="index">
          <div class="al-hover-shadow-radius">
            <UserInfoCard :user-info="item" />
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
  import ALImage from "../../../components/public/ALImage";
  import {request} from "../../../util/network/request";
  import {USER_GET_ALL_COMMON} from "../../../util/network/api/user/api-user";
  import UserInfoCard from "../../../components/public/UserInfoCard";
  export default {
    name: "UserRecommendComponent",
    //组件
    components: {UserInfoCard},
    //属性
    props: {
      // userRecommend: Array,
      userIdentity: Number,
    },

    //数据
    data() {
      return {
        userRecommend: []
      }
    },

    //挂载完成时
    mounted() {
      //摄影师推荐
      this.getUserRecommend(this.userIdentity);
    },

    //方法
    methods: {
      getUserRecommend(identity=1, pageNum = 1, pageSize = 0) {

        request({
          url: USER_GET_ALL_COMMON + identity + `?pageNum=${pageNum}&pageSize=${pageSize}`
        }).then(res => {
          if (identity === 1) {
            // console.log("==============摄影师用户信息");
            // console.log(res);
            this.userRecommend = res.data.data.list;
          } else if (identity === 2) {
            // console.log("==============模特用户信息");
            // console.log(res);
            this.userRecommend = res.data.data.list;

            //切割数组
            this.handleDataSize();
          }
        }).catch(err => {
          console.log(err)
        });
      },

      handleDataSize(){
        this.userRecommend = this.userRecommend.slice(0, 3);

      }


    },

    //计算属性
    computed: {},



    //监听
    watch: {}
  }
</script>

<style scoped>

</style>
